<template>
  <button @click="ok = true">打开一个对话框</button>
  <Teleport to="body" v-if="ok">
    <div class="box">
      <div>
        <button @click="ok = false">关闭</button>
      </div>
    </div>
  </Teleport>

</template>
<script lang="ts" setup>
import { ref } from 'vue';

let ok = ref(false)
</script>

<script setup lang="ts">

</script>

<style scoped lang="scss">
.box {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.4);
  display: flex;
  justify-content: center;
  align-items: center;

  div {
    width: 300px;
    height: 300px;
    background-color: white;
    display: flex;
    justify-content: center;
    align-items: center;
  }
}
</style>